<!DOCTYPE HTML>
<html>
<head>
	<meta charset="UTF-8">
	<title></title>
  <style type="text/css">
  body{
      margin:0;
      padding:0;
      border:0;
      outline:0;
      font-size:100%;
      vertical-align:baseline;
      background:transparent;
  }
  a{
	text-decoration : none;
  }
  /* Tables
  ---------------------------------------------------------------------*/

  table {
    border-spacing:1px;
    width:100%;
    background:#fff;
  }
  table th,table td {
    height:18px;
    line-height:18px;
    padding:8px 12px;
  }
  table th {
    background-color:#2A7AD2;
    color:#fff;
    text-align:left;
  }
  table tr{width:100%}
  table tr:hover{
    background-color:#ffa !important;
    background-color:#ffa;
  }
  input{
    width:80px;
  }
/********************************/

.pagelist{
  line-height:30px;
  height:30px;
}
.pagelist a { width:29px; height:30px; margin-right:4px; float:left; display:inline;background:url(../##IMGPATH#bg.png) no-repeat 0px -186px; text-align:center;line-height:25px; }
.pagelist a:hover { background-position:-30px -186px; color:#fff; text-decoration:none; }
.pagelist .prev,.pagelist .next{width:78px;background-position:-94px -186px;font-weight:bold;}
.pagelist .prev:hover,.pagelist .next:hover{background-position:-171px -186px; color:#fff;}
.pagelist .curPage, .pagelist .curPage:hover { background-position:-60px -186px; width:33px; color:#fff; font-size:18px; font-weight:bold;line-height:30px; } 

/*pagelist*/
.PageList { }

.PageList strong { text-align:center; float:left; display:inline; margin-right:30px; }
.PageList strong label{color:#00F; cursor:pointer;}
.PageList span{width:500px;text-align:center;background:red}

  </style>
  <script type="text/javascript" src="../##JSPATH#jquery-1.4.2.min.js"></script>
  <script type="text/javascript">
  var tablename = "##tablename#";
$(document).ready(function(){
  $("tr:odd").css({"background-color":"#ddd"});
  $("tr:even").css({"background-color":"#eee"});
  $("input:text,textarea").attr("disabled",true);
  $("input:submit").css({"width":"auto"});
  $("input:submit").click(function(){
    var thisparent = $(this).parent().parent();
    var thistype = $(this).attr("data-type");
    if(thistype=="edit"){
      $(this).attr("data-type","save").val("[保存]");
      thisparent.find("input:text,textarea").attr("disabled",false);
    }else if(thistype=="save"){
      saveajax(thisparent)
    }else if(thistype=="del"){
      delajax(thisparent);
    }
    
  });
  
  
  KanSea_pageindex(##allcount#,10,##pagenum#);
});
function delajax(obj){
  var id = $(obj).find("input[name='id']").val();
  $.ajax({
     type: "get",
     url: "manage.php?tn="+tablename+"&op=del&id="+id,
     success: function(msg){
       $(obj).remove();
     }
  });
}
function saveajax(obj){
  var id = $(obj).find("input[name='id']").val();
  var querystring = "";
  $(obj).find("input:text,textarea").each(function(){
    querystring+="&"+$(this).attr("name")+"="+$(this).val();
  });
  $.ajax({
     type: "get",
     url: "manage.php?tn="+tablename+"&op=update"+querystring,
     success: function(msg){
      $(obj).find("input[data-type='save']")
      .attr("data-type","edit").val("[編集]");
      $(obj).find("input:text,textarea").attr("disabled",true);
     }
  });
}
//////////////////////////////////////////////////////////////


var KanSea_pageindex = function(articlecount,pagesize,page){
  if(articlecount <= 1)
    articlecount =1;
    //articlecount =100;
  var KanSea_page_num=5;
  var Charset_Previous = "Prev";
  var Charset_Next = "Next";
  var KanSea_num;
  var KanSea_pagelist_html = "";
  var pageindex = Math.ceil(articlecount/pagesize);
  if(page<1){page=1;}
  if(page==1){
	  KanSea_pagelist_html += "<a href=\"javascript:;\" class=\"prev\">"+Charset_Previous+"</a>";
  }else
    KanSea_pagelist_html += "<a href=\"javascript:openurl("+(page-1)+");\" class=\"prev\">"+Charset_Previous+"</a>";
  for(i=0;i<(KanSea_page_num*2+1);i++){
    KanSea_num = page-KanSea_page_num+i;
    if(KanSea_num>0&&KanSea_num<=pageindex){
      KanSea_pagelist_html += "<a href=\"javascript:openurl("+KanSea_num+");\"";
      if(KanSea_num==page){
        //KanSea_Show_Page(articlecount,pagesize,page);
        KanSea_pagelist_html += " class=\"curPage\">"+KanSea_num;
      }else
        KanSea_pagelist_html +=">"+KanSea_num;
      KanSea_pagelist_html += "</a>";
    }
  }
  //KanSea_pagelist_html +="</div><div class=\"cnt\">";
  if(page==pageindex){
	  KanSea_pagelist_html += "<a href=\"javascript:;\" class=\"prev\">"+Charset_Next+"</a>";
  }else
    KanSea_pagelist_html += "<a href=\"javascript:openurl("+(page+1)+");\" class=\"next\">"+Charset_Next+"</a>";
  //KanSea_pagelist_html+="</div><div class=\"line_clear\"></div></div>";
  //alert(KanSea_pagelist_html);
  $("body").append("<div class=\"pagelist\">"+KanSea_pagelist_html+"</div>");
  $("body").prepend("<div class=\"pagelist\">"+KanSea_pagelist_html+"</div>");
};

function RequestQuerystring(key,value){
	pURL = window.location.href;
	if(pURL.indexOf("?")==-1){pURL+="?";}
	if(pURL.indexOf(key+"=")==-1){
    pURL +="&"+key+"="+value;
	}else{
    var reg = new RegExp("([\?\&])("+key+"=)([^\&]*)(\&?)","i");
    pURL = pURL.replace(reg,"$1$2"+value+"$4");
	}
	return pURL;
}
function openurl(pagenum){
	window.location.href = RequestQuerystring("p",pagenum);
	//window.open(RequestQuerystring("s",sortby));
}
  </script>
</head>
<body>
	<table>
    <thead>
      <tr>
        ##title#
      </tr>
    </thead>
    <tbody>
      ##body#
    </tbody>
    <tfoot>
      <tr>
        ##title#
      </tr>
    </tfoot>
	</table>
</body>
</html>